import React, { useState, useEffect } from 'react';
import { Button, Popconfirm, Tabs } from 'antd';
import { LoadingOutlined, RollbackOutlined } from '@ant-design/icons';
import {
  openNotification_util, checkdatavalid_util_formdata, fetchsync_util,
  resultdata_to_formdata, addkey_for_mxdata, use_dict_byzdmc, use_olreport_bybbbm,
  combile_mxdata_mxcol_util, convertISODateTimeToYYYYMMDDHHMMSS,
  view_item_util,
  checkdatavalid_util_formdata_mx,
} from '../util/util.js'
import Customfielditem_hook from '../newmes/customfielditem_hook.js'
import moment from 'moment'
import 'moment/locale/zh-cn'
import Xmpb_pjmx_hook from './xmpb_pjmx_hook.js';

import { SaveOutlined } from '@ant-design/icons';
import {
  use_xmpb_initformdata, use_xmpb_view_initformdata, use_xmpb_gys_column_initformdata,
  use_xmpb_pjmx_column_initformdata,
  use_xmpb_gystbfj_column_initformdata
} from './use_zbzx_config.js';
moment.locale('zh-cn')
var storage = window.localStorage;
import useStore from '../../useStore.js'
import { dropByCacheKey } from 'react-router-cache-route'
import { useLatest } from 'ahooks';
import { csc, round } from 'mathjs';
import Xmpb_gysmx_hook from './xmpb_gysmx_hook.js';


const Xmpb_form = () => {
  //动态数据源
  const [dynDatasObject, setdynDatasObject] = useState({
    dict_zbxs: [], query_gys: [], query_ry: [], dict_jjgz: []
  })
  const [isloading, setisloading] = useState(true)

  const [wlmxdata, setwlmxdata] = useState([])
  const [gysmxdata, setgysmxdata] = useState([])
  const [gysmxdata2, setgysmxdata2] = useState([])
  const [tbfjdata, settbfjdata] = useState([]) //供应商投标标书文件
  // const [pbmxdata, setpbmxdata] = useState([])
  // const [kbmxdata, setkbmxdata] = useState([])

  const [activeKey, setactiveKey] = useState(1)
  const [pjswmxcolums, setpjswmxcolums] = useState([]) //商务评分明细columen
  const [pjjsmxcolums, setpjjsmxcolums] = useState([]) //技术评分明细columen
  // const [pjmxdata, setpjmxdata] = useState([]) //商务评分明细数据
  const [pjswmxdata, setpjswmxdata] = useState([]) //商务评分明细数据
  const [pjjsmxdata, setpjjsmxdata] = useState([]) //技术评分明细数据
  const [pjmxdelidarr, setpjmxdelidarr] = useState([])
  const [supplierMap, setSupplierMap] = useState({}) //供应商名称映射

  const [gysmxcolums, setgysmxcolums] = useState(use_xmpb_gys_column_initformdata()) //供应商明细columen
  const [tbfjcolums, settbfjcolums] = useState(use_xmpb_gystbfj_column_initformdata()) //供应商投标标书文件columen

  /**
   * 强制刷新明细表 用于特殊场景
   */
  const [switche, setswitche] = useState(true);
  const forceupdate = () => { setswitche(false) }
  useEffect(() => { switche ? "1" : setswitche(true) }, [switche])

  const buildTree = (data) => {
    let treeData = []
    //一级分类数据
    let yjfl = data.filter(item => item.sjflid == '000')
    for (let i = 0; i < yjfl.length; i++) {
      //一级分类
      let yjflitem = { title: `(${yjfl[i].flbm})${yjfl[i].flmc}`, key: yjfl[i].flbm, value: yjfl[i].flmc, children: [] }
      //二级分类数据
      let ejfl = data.filter(item => item.sjflbm == yjfl[i].flbm)
      // console.log("ejfl", ejfl)
      for (let j = 0; j < ejfl.length; j++) {
        let ejflitem = { title: `(${ejfl[j].flbm})${ejfl[j].flmc}`, key: ejfl[j].flbm, value: ejfl[j].flmc, children: [] }
        let sjfl = data.filter(item => item.sjflbm == ejfl[j].flbm)
        for (let k = 0; k < sjfl.length; k++) {
          let sjflitem = { title: `(${sjfl[k].flbm})${sjfl[k].flmc}`, key: sjfl[k].flbm, value: sjfl[k].flmc }
          //往二级分类中添加二级分类
          ejflitem.children.push(sjflitem)
        }
        //往一级分类中添加二级分类
        yjflitem.children.push(ejflitem)
      }
      treeData.push(yjflitem)
    }
    return treeData
  };

  const init = async () => {
    setisloading(true)
    let rtdata = await fetchsync_util("/admin/baseinfo/wlfllb", 'POST', {}, "json")
    // console.log("rtdata", rtdata)
    var treedata = buildTree(rtdata.resultdata);
    var dictObj = await use_dict_byzdmc(["dict_zbxs", "dict_jjgz"])
    var bbObj = await use_olreport_bybbbm(["query_ry", "query_gys", "query_wl"])
    dynDatasObject.dict_zbxs = dictObj.dict_zbxs
    dynDatasObject.dict_jjgz = dictObj.dict_jjgz
    dynDatasObject.query_ry = bbObj.query_ry
    dynDatasObject.query_gys = bbObj.query_gys
    dynDatasObject.query_wl = bbObj.query_wl
    formdata.zbpl.selectdata = treedata
    setdynDatasObject({ ...dynDatasObject })
    setisloading(false)
  }

  //主表数据
  const [formdata, setformdata] = useState(JSON.parse(storage.pre_xmpb_item).type == "view" ? use_xmpb_view_initformdata() : use_xmpb_initformdata())
  const { setnowroute, collapsed } = useStore();

  //加载主表数据
  const loadformdata = async (id, pblx) => {
    let rtdata = await fetchsync_util("/admin/zbzx/query_xmpb_byid", 'POST', { id, pblx }, "json")
    if (!rtdata.rtstatus) {
      openNotification_util("该项目不存在")
      return
    }
    let wlmxdata = rtdata.resultdata.wlmxdata
    let gysmxdata = rtdata.resultdata.gysmxdata
    let pbmxdata = rtdata.resultdata.pbmxdata
    let kbmxdata = rtdata.resultdata.kbmxdata
    let ttmxdata = rtdata.resultdata.ttmxdata
    // let gysbjmxdata = rtdata.resultdata.gysbjmxdata
    let tbbjdata = rtdata.resultdata.tbbjdata
    rtdata.resultdata.formdata.ybjzsj = rtdata.resultdata.formdata.ybjzsj ? convertISODateTimeToYYYYMMDDHHMMSS(rtdata.resultdata.formdata.ybjzsj) : ""
    rtdata.resultdata.formdata.kbsj = rtdata.resultdata.formdata.kbsj ? convertISODateTimeToYYYYMMDDHHMMSS(rtdata.resultdata.formdata.kbsj) : ""
    rtdata.resultdata.formdata.fbsj = rtdata.resultdata.formdata.fbsj ? convertISODateTimeToYYYYMMDDHHMMSS(rtdata.resultdata.formdata.fbsj) : ""
    rtdata.resultdata.formdata.pbkssj = rtdata.resultdata.formdata.pbkssj ? convertISODateTimeToYYYYMMDDHHMMSS(rtdata.resultdata.formdata.pbkssj) : ""
    rtdata.resultdata.formdata.pbjssj = rtdata.resultdata.formdata.pbjssj ? convertISODateTimeToYYYYMMDDHHMMSS(rtdata.resultdata.formdata.pbjssj) : ""
    // If type is view, set jsbdf and swbdf columns to readonly
    setformdata({ ...formdata, ...resultdata_to_formdata(rtdata.resultdata.formdata, formdata) });
    setgysmxdata(addkey_for_mxdata(rtdata.resultdata.kbmxdata))
    setgysmxdata2(addkey_for_mxdata(rtdata.resultdata.gysmxdata))
    setwlmxdata(addkey_for_mxdata(rtdata.resultdata.wlmxdata))
    settbfjdata(addkey_for_mxdata(rtdata.resultdata.tbfjdata.filter((item)=>item.gys_fj)))
    // setgysmxdata(addkey_for_mxdata(rtdata.resultdata.gysmxdata))
    // setpbmxdata(addkey_for_mxdata(rtdata.resultdata.pbmxdata))
    //商务明细columen
    let swColumm = [
      { ifdb: false, bt: false, defalut_v: "", value: "", title: '序号', dataIndex: 'xuhao', inputType: "readonly", width: "61px" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: 'id', dataIndex: 'id', inputType: "none" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: 'mainid', dataIndex: 'mainid', inputType: "none" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: '供应商名称', dataIndex: 'gysmc', inputType: "readonly",width:'15rem'},
      { ifdb: true, bt: false, defalut_v: "", value: "", title: '供应商id', dataIndex: 'gysid', inputType: "none" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: '物料明细id', dataIndex: 'wlmxid', inputType: "none" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: '基准价', dataIndex: 'bdj', inputType: "readonly",width:'5rem'},
      // { ifdb: true, bt: false, defalut_v: "", value: "", title: '标前询价报价', dataIndex: 'bqxjbj', inputType: "readonly" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: '投标价', dataIndex: 'tbj', inputType: "readonly",width:'5rem'},
      { ifdb: true, bt: false, defalut_v: "", value: "", title: '系统评分', dataIndex: 'xtpf', inputType: "readonly",width:'5rem',
        message:'系统评分= 商务标基准分 加上（投标价-基准价）/单分差值 (不超过最大分差值)'
      },
    ]
    //技术明细columen
    let jsColumm = [
      { ifdb: false, bt: false, defalut_v: "", value: "", title: '序号', dataIndex: 'xuhao', inputType: "readonly", width: "61px" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: 'id', dataIndex: 'id', inputType: "none" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: 'mainid', dataIndex: 'mainid', inputType: "none" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: '供应商名称', dataIndex: 'gysmc', inputType: "readonly" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: '供应商id', dataIndex: 'gysid', inputType: "none" },
      { ifdb: true, bt: false, defalut_v: "", value: "", title: '物料明细id', dataIndex: 'wlmxid', inputType: "none" },
    ]
    rtdata.resultdata.pbmxdata.forEach(item => {
      if (item.pblx == "商务标书") {
        swColumm.push({
          ifdb: true, bt: false, defalut_v: "", value: "", title: item.pbr, dataIndex: item.pbr, inputType: "input_number_item",
        })
      } else if (item.pblx == "技术标书") {
        jsColumm.push({
          ifdb: true, bt: false, defalut_v: "", value: "", title: item.pbr, dataIndex: item.pbr, inputType: "input_number_item",
        })
      } else {
        // 综合评标：两边都需要参评
        swColumm.push({
          ifdb: true, bt: false, defalut_v: "", value: "", title: item.pbr, dataIndex: item.pbr, inputType: "input_number_item",
        })
        jsColumm.push({
          ifdb: true, bt: false, defalut_v: "", value: "", title: item.pbr, dataIndex: item.pbr, inputType: "input_number_item",
        })
      }
    })
    swColumm.push({
      ifdb: true, bt: false, defalut_v: "", value: "", title: '平均分', dataIndex: 'zzdf', inputType: "readonly",width:'5rem'
    })
    jsColumm.push({
      ifdb: true, bt: false, defalut_v: "", value: "", title: '平均分', dataIndex: 'zzdf', inputType: "readonly",width:'5rem'
    })
    if (JSON.parse(storage.pre_xmpb_item).type == "view") {
      setpjswmxcolums(view_item_util(swColumm))
      setpjjsmxcolums(view_item_util(jsColumm))
    }
    else {
      setpjswmxcolums(swColumm)
      setpjjsmxcolums(jsColumm)
    }
    let pjswmxdata = []
    let pjjsmxdata = []
    for (let i = 0; i < wlmxdata.length; i++) {
      let wlmxitem = wlmxdata[i]
      for (let j = 0; j < gysmxdata.length; j++) {
        let gysmxitem = gysmxdata[j]
        // 如果该物料供应商已被淘汰，则不显示
        // if (rtdata.resultdata.ttmxdata.some(item => item.bjwlmxid == wlmxitem.id &&
        //   item.gysid == gysmxitem.gysid)) {
        //   continue
        // }
        let swobj = {}
        let jsobj = {}
        //如果存在投标价格，则计算系统评分
        if (tbbjdata.some(item => item.bjwlid == wlmxitem.id && item.tbgysid == gysmxitem.gysid)) {
          let tbbjitem = tbbjdata.find(item => item.bjwlid == wlmxitem.id &&
            item.tbgysid == gysmxitem.gysid)
          swobj.tbj = tbbjitem.tbje
          //计算系统评分
          if (rtdata.resultdata.formdata.dfcj && rtdata.resultdata.formdata.zdfcz && rtdata.resultdata.formdata.swjzf) {
            if (tbbjitem.tbje) {
              let cz = rtdata.resultdata.formdata.jjgz=='价高优先' ? tbbjitem.tbje - wlmxitem.bdj : wlmxitem.bdj - tbbjitem.tbje
              let xtpf = ((cz) / rtdata.resultdata.formdata.dfcj) * 1 + rtdata.resultdata.formdata.swjzf * 1
              if (xtpf * 1 > rtdata.resultdata.formdata.swjzf * 1 && xtpf * 1 > (rtdata.resultdata.formdata.swjzf * 1 + rtdata.resultdata.formdata.zdfcz * 1)) {
                xtpf = rtdata.resultdata.formdata.swjzf * 1 + rtdata.resultdata.formdata.zdfcz * 1
              }
              else if (xtpf * 1 < rtdata.resultdata.formdata.swjzf * 1 && xtpf * 1 < (rtdata.resultdata.formdata.swjzf * 1 - rtdata.resultdata.formdata.zdfcz * 1)) {
                xtpf = rtdata.resultdata.formdata.swjzf * 1 - rtdata.resultdata.formdata.zdfcz * 1
              }
              swobj.xtpf = round(xtpf, 0)
            }
            else {
              swobj.xtpf = ''
            }
          }
          else {
            swobj.xtpf = ''
          }
        }
        else {
          swobj.xtpf = ''
        }
        //获取标前询价价格
        // if (rtdata.resultdata.gysbjmxdata.some(item => item.bjwlmxid == wlmxitem.id &&
        //   item.gysid == gysmxitem.gysid)) {
        //   let tbbjitem = rtdata.resultdata.gysbjmxdata.find(item => item.bjwlmxid == wlmxitem.id &&
        //     item.gysid == gysmxitem.gysid)
        //   obj.bqxjbj = tbbjitem.bj
        // }
        if (kbmxdata.some(item => item.wlmxid == wlmxitem.id && item.gysid == gysmxitem.gysid)) {
          //商务标
          swobj.xuhao = i * gysmxdata.length + (j + 1);
          swobj.id = wlmxitem.id + gysmxitem.id;
          swobj.mainid = wlmxitem.mainid;
          swobj.wlmxid = wlmxitem.id;
          swobj.gysmc = rtdata.resultdata.gysmxdata[j].gysmc;
          swobj.gysid = rtdata.resultdata.gysmxdata[j].gysid
          swobj.bdj = wlmxitem.bdj
          //技术标
          jsobj.xuhao = i * gysmxdata.length + (j + 1);
          jsobj.id = wlmxitem.id + gysmxitem.id;
          jsobj.mainid = wlmxitem.mainid;
          jsobj.wlmxid = wlmxitem.id;
          jsobj.gysmc = rtdata.resultdata.gysmxdata[j].gysmc;
          jsobj.gysid = rtdata.resultdata.gysmxdata[j].gysid

          let swtotal = 0
          let jstotal = 0
          for (let k = 0; k < pbmxdata.length; k++) {
            let pbmxitem = pbmxdata[k]
            let pbwy = pbmxitem.pbr
            if (pbmxitem.pblx == "商务标书") {
              swobj[pbwy] = kbmxdata.find(item => item.wlmxid == wlmxitem.id
                && item.gysid == gysmxitem.gysid && item.pbwy == pbwy)?.swbdf ?? 0
              swtotal += kbmxdata.find(item => item.wlmxid == wlmxitem.id
                && item.gysid == gysmxitem.gysid && item.pbwy == pbwy)?.swbdf ?? 0
            }
            else if (pbmxitem.pblx == "技术标书") {
              jsobj[pbwy] = kbmxdata.find(item => item.wlmxid == wlmxitem.id
                && item.gysid == gysmxitem.gysid && item.pbwy == pbwy)?.jsbdf ?? 0
              jstotal += kbmxdata.find(item => item.wlmxid == wlmxitem.id
                && item.gysid == gysmxitem.gysid && item.pbwy == pbwy)?.jsbdf ?? 0
            }
            else {
              // 综合评标：两边都需要读取
              swobj[pbwy] = kbmxdata.find(item => item.wlmxid == wlmxitem.id
                && item.gysid == gysmxitem.gysid && item.pbwy == pbwy)?.swbdf ?? 0
              swtotal += kbmxdata.find(item => item.wlmxid == wlmxitem.id
                && item.gysid == gysmxitem.gysid && item.pbwy == pbwy)?.swbdf ?? 0
              jsobj[pbwy] = kbmxdata.find(item => item.wlmxid == wlmxitem.id
                && item.gysid == gysmxitem.gysid && item.pbwy == pbwy)?.jsbdf ?? 0
              jstotal += kbmxdata.find(item => item.wlmxid == wlmxitem.id
                && item.gysid == gysmxitem.gysid && item.pbwy == pbwy)?.jsbdf ?? 0
            }
          }
          let swcount = kbmxdata.filter(item => item.bslx == "商务标书" && item.swbdf &&
            item.wlmxid == wlmxitem.id && item.gysid == gysmxitem.gysid).length
          let jscount = kbmxdata.filter(item => item.bslx == "技术标书" && item.jsbdf &&
            item.wlmxid == wlmxitem.id && item.gysid == gysmxitem.gysid).length
          // console.log(swtotal, swcount,jstotal, jscount,gysmxitem.gysmc, wlmxitem.wlmc, swobj.xtpf, '111111111111');
          swobj.zzdf = swcount > 0 ? ((swtotal / swcount) + swobj.xtpf * 1).toFixed(1) : 0
          jsobj.zzdf = jscount > 0 ? ((jstotal / jscount)).toFixed(1) : 0
        }
        else {
          //商务标
          swobj.xuhao = i * gysmxdata.length + (j + 1);
          swobj.id = wlmxitem.id + gysmxitem.id;
          swobj.mainid = wlmxitem.mainid;
          swobj.wlmxid = wlmxitem.id;
          swobj.gysmc = rtdata.resultdata.gysmxdata[j].gysmc;
          swobj.gysid = rtdata.resultdata.gysmxdata[j].gysid
          swobj.bdj = wlmxitem.bdj
          swobj.zzdf = ''
          //技术标
          jsobj.xuhao = i * gysmxdata.length + (j + 1);
          jsobj.id = wlmxitem.id + gysmxitem.id;
          jsobj.mainid = wlmxitem.mainid;
          jsobj.wlmxid = wlmxitem.id;
          jsobj.gysmc = rtdata.resultdata.gysmxdata[j].gysmc;
          jsobj.gysid = rtdata.resultdata.gysmxdata[j].gysid
          jsobj.zzdf = ''
          for (let k = 0; k < pbmxdata.length; k++) {
            let pbmxitem = pbmxdata[k]
            let pbr = pbmxitem.pbr
            if (pbmxitem.pblx == "商务标书") {
              swobj[pbr] = ""
            }
            else if (pbmxitem.pblx == "技术标书") {
              jsobj[pbr] = ""
            }
            else {
              // 综合评标：两边都占位
              swobj[pbr] = ""
              jsobj[pbr] = ""
            }
          }
        }
        // pjmxdata.push(obj)
        pjswmxdata.push(swobj)
        pjjsmxdata.push(jsobj)
      }
    }
    // setpjmxdata(pjmxdata)
    setpjswmxdata(pjswmxdata)
    setpjjsmxdata(pjjsmxdata)
    setswitche(false)
  }

  // 页面进入加载数据
  useEffect(() => {

    loadformdata(JSON.parse(storage.pre_xmpb_item).data.id, JSON.parse(storage.pre_xmpb_item).data.pblx)

    // if (JSON.parse(storage.pre_xmpb_item).data.pblx == "商务标书") {
    //   let columns = use_xmpb_pjmx_column_initformdata();
    //   columns = columns.map(col => {
    //     if (col.dataIndex === 'jsbdf') {
    //       return { ...col, inputType: 'none' };
    //     }
    //     return col;
    //   });
    //   setpjmxcolums(columns);
    // } else {
    //   let columns = use_xmpb_pjmx_column_initformdata();
    //   columns = columns.map(col => {
    //     if (col.dataIndex === 'swbdf') {
    //       return { ...col, inputType: 'none' };
    //     }
    //     return col;
    //   });
    //   setpjmxcolums(columns);
    // }

    setisloading(false)
    // }
  }, [])




  //设置value
  const setfield = (onekey, value, settype) => {
    if (settype == 'single') {
      if (onekey == "zbpl") {
        var newitem = formdata[onekey]
        newitem.value = value.value
        let newformdata = Object.assign({}, formdata, { [onekey]: newitem });
        setformdata(newformdata)
      }
      else {
        var newitem = formdata[onekey]
        newitem.value = value
        let newformdata = Object.assign({}, formdata, { [onekey]: newitem });
        setformdata(newformdata)
      }
    }
    else if (settype == "muti") {
      let [tansferarr, selectrow, newformdata] = [onekey, value, {}];
      tansferarr.forEach(item => {
        var newitem = formdata[item.target]
        newitem.value = selectrow ? selectrow[item.origin] : ""
        newformdata = Object.assign({}, formdata, { [item.target]: newitem });
      })
      setformdata(newformdata)
    }

  }


  const handleupload = async (type) => {
    // console.log(pjmxcolums, "pjmxcolums");
    // var newswdatalist = combile_mxdata_mxcol_util(pjswmxdata, pjswmxcolums)
    // // console.log(newdatalist, "newdatalist");
    // if (!checkdatavalid_util_formdata_mx(newswdatalist)) {
    //   openNotification_util("商务标明细必填校验不通过，无法保存")
    //   return
    // }

    // var newjsdatalist = combile_mxdata_mxcol_util(pjjsmxdata, pjjsmxcolums)
    // // console.log(newdatalist, "newdatalist");
    // if (!checkdatavalid_util_formdata_mx(newjsdatalist)) {
    //   openNotification_util("技术标明细必填校验不通过，无法保存")
    //   return
    // }
    await fetchsync_util("/admin/zbzx/xmpb_tjpf", 'POST', { pjswmxdata, pjjsmxdata, gysmxdata, id: JSON.parse(storage.pre_xmpb_item).data.id, formdata, storage, pblx: JSON.parse(storage.pre_xmpb_item).data.pblx }, "json")

    dropByCacheKey('xmsp_list')
    dropByCacheKey('xmsp_form')
    setnowroute({ route: "/shipSRM/zbzx/xmpb_list", title: "项目评标", closeroute: "/shipSRM/zbzx/xmpb_form" })

  }

  const handleBackTolist = () => {
    setnowroute({ route: "/shipSRM/zbzx/xmpb_list", title: "项目评标", closeroute: "/shipSRM/zbzx/xmpb_form" })
  }


  const renderfileditem = () => {
    var formdataarr = []
    for (var formitemkey in formdata) {
      formdata[formitemkey].inputType == "none" ? "" : formdataarr.push(formdata[formitemkey])
    }
    var renderstr = formdataarr.map(item => {
      var rtitem = item.input_type == "space_item" ?
        <Customfielditem_hook form={formdata} item={{ inputType: "none" }}
          handlechange={(key, value, settype) => { setfield(key, value, settype) }} />
        :
        <Customfielditem_hook form={formdata} item={formdata[item.dataIndex]}
          dynDatasObject={dynDatasObject}
          handlechange={(key, value, settype) => { setfield(key, value, settype) }} />
      return rtitem
    }
    )
    return renderstr
  }

    return (

    <div style={{
      height: "94%", backgroundColor: `#F1F1F1`, right: "1%", top: "5.9vh", overflow: "hidden",
      backgroundSize: "100% 100%", width: collapsed ? "94%" : "84%", position: "absolute", color: "white", fontSize: "0.8rem"
    }}
    data-page-type="form">

      <div style={{width:"100%",height:"100%",backgroundColor:"white",overflow:"auto"}}>
      <div style={{
        width: "100%", height: "7%", position: "sticky", top: "1%", backgroundColor: "white", color: "black", display: "flex",
        zIndex: 105, borderBottom: "2px solid #a91f24"
      }}>


        <div style={{ width: "40%", textAlign: "left", paddingRight: "1rem", display: "flex", alignItems: "center", fontWeight: "600" }}>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          工具栏
        </div>

        <div style={{ width: "60%", textAlign: "right", paddingRight: "1rem" }}>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          {JSON.parse(storage.pre_xmpb_item).type !== "view" ?
            <Popconfirm title="确定要提交评分吗？" onConfirm={() => handleupload()}>
              <Button type="primary"
                style={{ width: "6rem", height: '1.7rem', fontSize: "0.7rem", borderRadius: "5px", marginTop: "0.2rem" }}>
                <SaveOutlined />提交评分
              </Button>
            </Popconfirm> :
            <Button type="default" onClick={handleBackTolist}
              style={{ width: "6rem", height: '1.7rem', fontSize: "0.7rem", borderRadius: "5px", marginTop: "0.2rem" }}>
              <RollbackOutlined />返回列表
              </Button>
            }
          </div>

        </div>

      <div style={styles.kshcontainer}>
        <div style={{
          fontSize: "0.7rem", position: "relative", width: "96%", marginLeft: "2%", backgroundColor: "", display: "flex",
          textIndent: "1rem", justifyContent: "flex-start", alignContent: "flex-start", flexWrap: "wrap", marginBottom: "2rem"
        }}>
          {renderfileditem()}
        </div>
        {/* 主表区域结束 */}


        {/* 供应商商务评分明细区域 */}
        <div style={{
          height: "1.2rem", marginLeft: "2%", position: "relative", width: "96%", textIndent: "0.5rem", color: "#666666",
          backgroundColor: "white", lineHeight: "1.2rem", fontSize: "14px", fontWeight: "500", textAlign: "left", borderLeftStyle: "solid",
          borderWidth: "0.3rem", borderColor: "#a91f24", marginTop: "1rem", marginBottom: "0.5rem", letterSpacing: "0.05rem"
        }}>
          供应商商务评分明细
        </div>
        <div style={{
          fontSize: "0.7rem", position: "relative", width: "96%", marginLeft: "2%", backgroundColor: "", display: "flex",
          textIndent: "1rem", justifyContent: "flex-start", alignContent: "flex-start", flexWrap: "wrap"
        }}>
          {isloading ?
            (<div style={{ width: "10%", height: "10%", position: "absolute", left: "50%", top: "49%", color: "#14d9cc" }}>            <LoadingOutlined /></div>)
            :
            <div style={{ position: "relative", width: "100%", overflowX: "auto", marginBottom: "1rem" }}>
              {wlmxdata.length > 0 && (
                <Tabs defaultActiveKey={activeKey} onChange={(key) => { setactiveKey(key) }} className='task-tabs' >
                  {Array.from({ length: wlmxdata.length }, (_, i) => (
                    <Tabs.TabPane tab={<span>{wlmxdata[i].wlmc}</span>} key={i + 1}>
                      {switche && <Xmpb_pjmx_hook colmuns={pjswmxcolums}
                        datasource={addkey_for_mxdata(pjswmxdata.filter(item => item.wlmxid == wlmxdata[i].id))}
                        styleobj={{ height: "70%" }}
                        dynDatasObject={dynDatasObject}
                        formdata={formdata}
                        handledelid={ids => { ids.length !== 0 ? setpjmxdelidarr([...pjmxdelidarr, ...ids]) : ''; }}
                        handgetmxdata={(tabledata) => {
                          addkey_for_mxdata(tabledata)
                          setpjswmxdata(tabledata)
                        }}
                        pjswmxdata={pjswmxdata}
                        ifshowaddbtn={false}
                        handlechangeFormdata={(data) => {
                          setformdata(data)
                        }}
                        forceupdate={forceupdate}
                      />}
                    </Tabs.TabPane>
                  ))}
                </Tabs>
              )}
            </div>
          }
        </div>
        {/* 供应商技术评分明细 */}
        <div style={{
          height: "1.2rem", marginLeft: "2%", position: "relative", width: "96%", textIndent: "0.5rem", color: "#666666",
          backgroundColor: "white", lineHeight: "1.2rem", fontSize: "14px", fontWeight: "500", textAlign: "left", borderLeftStyle: "solid",
          borderWidth: "0.3rem", borderColor: "#a91f24", marginTop: "1rem", marginBottom: "0.5rem", letterSpacing: "0.05rem"
        }}>
          供应商技术评分明细
        </div>
        <div style={{
          fontSize: "0.7rem", position: "relative", width: "96%", marginLeft: "2%", backgroundColor: "", display: "flex",
          textIndent: "1rem", justifyContent: "flex-start", alignContent: "flex-start", flexWrap: "wrap"
        }}>
          {isloading ?
            (<div style={{ width: "10%", height: "10%", position: "absolute", left: "50%", top: "49%", color: "#14d9cc" }}>            <LoadingOutlined /></div>)
            :
            <div style={{ position: "relative", width: "100%", overflowX: "auto", marginBottom: "1rem" }}>
              {wlmxdata.length > 0 && (
                <Tabs defaultActiveKey={activeKey} onChange={(key) => { setactiveKey(key) }} className='task-tabs' >
                  {Array.from({ length: wlmxdata.length }, (_, i) => (
                    <Tabs.TabPane tab={<span>{wlmxdata[i].wlmc}</span>} key={i + 1}>
                      {switche && <Xmpb_pjmx_hook colmuns={pjjsmxcolums} datasource={addkey_for_mxdata(pjjsmxdata.filter(item => item.wlmxid == wlmxdata[i].id))}
                        styleobj={{ height: "70%" }}
                        dynDatasObject={dynDatasObject}
                        formdata={formdata}
                        handledelid={ids => { ids.length !== 0 ? setpjmxdelidarr([...pjmxdelidarr, ...ids]) : ''; }}
                        handgetmxdata={(tabledata) => {
                          addkey_for_mxdata(tabledata)
                          setpjjsmxdata(tabledata)
                        }}
                        pjjsmxdata={pjjsmxdata}
                        ifshowaddbtn={false}
                        handlechangeFormdata={(data) => {
                          setformdata(data)
                        }}
                        forceupdate={forceupdate}
                      />}
                    </Tabs.TabPane>
                  ))}
                </Tabs>
              )}
            </div>
          }
        </div>
        {/* 供应商信息 */}
        <div style={{
          height: "1.2rem", marginLeft: "2%", position: "relative", width: "96%", textIndent: "0.5rem", color: "#666666",
          backgroundColor: "white", lineHeight: "1.2rem", fontSize: "14px", fontWeight: "500", textAlign: "left", borderLeftStyle: "solid",
          borderWidth: "0.3rem", borderColor: "#a91f24", marginTop: "1rem", marginBottom: "0.5rem", letterSpacing: "0.05rem"
        }}>
          供应商信息
        </div>
        <div style={{
          fontSize: "0.7rem", position: "relative", width: "96%", marginLeft: "2%", backgroundColor: "", display: "flex",
          textIndent: "1rem", justifyContent: "flex-start", alignContent: "flex-start", flexWrap: "wrap"
        }}>
          {isloading ?
            (<div style={{ width: "10%", height: "10%", position: "absolute", left: "50%", top: "49%", color: "#14d9cc" }}>            <LoadingOutlined /></div>)
            :
            <div style={{ position: "relative", width: "100%", overflowX: "auto", marginBottom: "1rem" }}>
              {wlmxdata.length > 0 && (
                <Tabs defaultActiveKey={activeKey} onChange={(key) => { setactiveKey(key) }} className='task-tabs' >
                  {Array.from({ length: wlmxdata.length }, (_, i) => (
                    <Tabs.TabPane tab={<span>{wlmxdata[i].wlmc}</span>} key={i + 1}>
                      {switche && <Xmpb_gysmx_hook colmuns={gysmxcolums}
                        datasource={addkey_for_mxdata(gysmxdata.filter(item => item.wlmxid == wlmxdata[i].id).map(
                          (item, index) => {
                            return {
                              ...item,
                              pm: index + 1
                            }
                          }
                        ))}
                        styleobj={{ height: "70%" }}
                        dynDatasObject={dynDatasObject}
                        formdata={formdata}
                        handledelid={ids => { ids.length !== 0 ? setpjmxdelidarr([...pjmxdelidarr, ...ids]) : ''; }}
                        handgetmxdata={(tabledata) => {
                          addkey_for_mxdata(tabledata)
                          setgysmxdata(tabledata)
                        }}
                        gysmxdata={gysmxdata}
                        pjswmxdata={pjswmxdata}
                        pjjsmxdata={pjjsmxdata}
                        ifshowaddbtn={false}
                        handlechangeFormdata={(data) => {
                          setformdata(data)
                        }}
                        forceupdate={forceupdate}
                      />}
                    </Tabs.TabPane>
                  ))}
                </Tabs>
              )}
            </div>
          }
        </div>

        {/* 供应商投标标书文件 */}
        <div style={{
          height: "1.2rem", marginLeft: "2%", position: "relative", width: "96%", textIndent: "0.5rem", color: "#666666",
          backgroundColor: "white", lineHeight: "1.2rem", fontSize: "14px", fontWeight: "500", textAlign: "left", borderLeftStyle: "solid",
          borderWidth: "0.3rem", borderColor: "#a91f24", marginTop: "1rem", marginBottom: "0.5rem", letterSpacing: "0.05rem"
        }}>
          供应商投标标书文件
        </div>
        <div style={{
          fontSize: "0.7rem", position: "relative", width: "96%", marginLeft: "2%", backgroundColor: "", display: "flex",
          textIndent: "1rem", justifyContent: "flex-start", alignContent: "flex-start", flexWrap: "wrap"
        }}>
          {isloading ?
            (<div style={{ width: "10%", height: "10%", position: "absolute", left: "50%", top: "49%", color: "#14d9cc" }}>            <LoadingOutlined /></div>)
            :
            <div style={{ position: "relative", width: "100%", overflowX: "auto", marginBottom: "1rem" }}>
              {gysmxdata2.length > 0 && (
                <Tabs defaultActiveKey={activeKey} onChange={(key) => { setactiveKey(key) }} className='task-tabs' >
                  {Array.from({ length: gysmxdata2.length }, (_, i) => (
                    <Tabs.TabPane tab={<span>{gysmxdata2[i].gysmc}</span>} key={i + 1}>
                      {switche && <Xmpb_pjmx_hook colmuns={tbfjcolums}
                        datasource={addkey_for_mxdata(tbfjdata.filter(item => item.gysid == gysmxdata2[i].gysid).map(
                          (item, index) => {
                            return {
                              ...item,
                            }
                          }
                        ))}
                        styleobj={{ height: "70%" }}
                        dynDatasObject={dynDatasObject}
                        formdata={formdata}
                        handledelid={ids => { ids.length !== 0 ? setpjmxdelidarr([...pjmxdelidarr, ...ids]) : ''; }}
                        handgetmxdata={(tabledata) => {
                          addkey_for_mxdata(tabledata)
                          setgysmxdata(tabledata)
                        }}
                        ifshowaddbtn={false}
                        handlechangeFormdata={(data) => {
                          setformdata(data)
                        }}
                        forceupdate={forceupdate}
                      />}
                    </Tabs.TabPane>
                  ))}
                </Tabs>
              )}
            </div>
          }
        </div>

      </div>
      </div>
    </div>
  )
}


export default Xmpb_form
var styles = {
  maincontainer: {
    height: "100vh", backgroundColor: `white`,
    backgroundSize: "100% 100%", width: "100%", position: "absolute", left: "0", color: "white", fontSize: "0.8rem"
  },
  topcontainer: {
    width: "100%", height: "10vw", backgroundImage: "linear-gradient(to bottom,#e4e5eb , white)", paddingTop: "3vw",
    position: "relative", fontSize: "0.89rem", textIndent: "2rem", fontWeight: "800", color: "#a91f24", borderRadius: "0 0 15px 15px"
  },
  butdcstyle: { paddingLeft: "1vw", paddingRight: "1vw", height: "2vw", position: "absolute", right: "1%", top: "0%", backgroundColor: "#a91f24", fontSize: "0.8vw", borderRadius: "0.4rem", borderRadius: "0 0 0.3vw 0.3vw" },
  butmainstyle: { paddingLeft: "1vw", height: "2vw", position: "absolute", right: "6.5%", top: "0%", backgroundColor: "#a91f24", fontSize: "0.8vw", borderRadius: "0.4rem", borderRadius: "0 0 0.3vw 0.3vw" },
  butbackstyle: { borderRadius: "0.4rem", backgroundColor: "#a91f24", height: "2vw", position: "absolute", right: "12%", top: "0%", fontSize: "0.8vw", borderRadius: "0 0 0.3vw 0.3vw" },
  kshcontainer: {
    width: "98%", position: "relative", backgroundColor: "white", color: "#666",
    borderRadius: "10px", paddingBottom: "2rem", overflow: "visible"
  },
}